/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2008 Intel Corporation. All Rights Reserved.
//
//
*/

#ifndef __UMC_AVS_ENC_ME_ESTIMATOR_H
#define __UMC_AVS_ENC_ME_ESTIMATOR_H

#include "umc_avs_enc_compressor.h"
#include "umc_avs_processing_unit.h"
#include "umc_avs_list.h"
#include "umc_avs_enc_compressor.h"
#include "umc_me.h"
#include "umc_me_structures.h"

namespace UMC
{

class AVSME : public AVSCompressor
{
public:
    // Default constructor
    AVSME(void);
    // Destructor
    virtual
    ~AVSME(void);

    //
    // Initialization functions
    Status SetMEParams(MeInitParams *MEParamsInit);
    Status SetMEParams(void);
    //Status SetMEFrames(void);
    //

    // Set ME parameters
    inline
    void SetMEContext(AVS_ME_CONTEXT &meCtx);
    // Get ME parameters
    inline
    AVS_ME_CONTEXT & GetMEContext(void);

    //
    // Combined functions to estimate
    //
    void EstimateIMacroBlocksRow(void);
    void EstimatePMacroBlocksRow(void);
    void EstimateBMacroBlocksRow(void);
    
    Status EstimateISlice ();
    Status EstimatePSlice ();
    Status EstimateBSlice ()/* {m_meCtx.MbIndex = m_meCtx.MbWidth * m_meCtx.MbHeight;return UMC_OK;}*/;

    // ReconstructMotionVectorsBSliceDirect
    void ReconstructDirectMotionVectors(void);

    // init flag
    bool isAVSMEInit;

protected:

    // Prepare disassembling variables
    void PrepareDisassembling(void);

    // Update disassembling variables
    void AdvanceDisassembling(void);

    // Finalize disassembling stuff, set specials flags
    void FinalizeDisassembling(void);

    AVS_ME_CONTEXT m_meCtx;                                     // (AVS_DISASSEMBLING_CONTEXT) disassembling context
    //MeVC1 m_avs_me;                                                // (ME *) pointer to being used Motion estimation
    //MeH264 m_avs_me;
    MeAVS m_avs_me;
    
    MeParams MEParams;
    MeInitParams MEParamsInit;

};

inline
void AVSME::SetMEContext(AVS_ME_CONTEXT &meCtx)
{
    m_meCtx = meCtx;

} // void AVSME::SetMEContext(AVS_ME_CONTEXT &meCtx)

inline
AVS_ME_CONTEXT & AVSME::GetMEContext(void)
{
    return m_meCtx;

} // AVS_ME_CONTEXT & AVSME::GetMEContext(void)


} // namespace UMC

#endif // __UMC_AVS_ENC_ME_ESTIMATOR_H
